<template>
    <a-drawer
        :title="formData.wfAuditInfoId ? '编辑审批记录' : '增加审批记录'"
        :width="600"
        :visible="visible"
        :destroy-on-close="true"
        :footer-style="{ textAlign: 'right' }"
        @close="onClose"
    >
        <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
            <a-form-item label="PROC_INST_ID：" name="procInstId">
                <a-input v-model:value="formData.procInstId" placeholder="请输入PROC_INST_ID" allow-clear />
            </a-form-item>
            <a-form-item label="PROCESS_NAME：" name="processName">
                <a-input v-model:value="formData.processName" placeholder="请输入PROCESS_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="TASK_ID：" name="taskId">
                <a-input v-model:value="formData.taskId" placeholder="请输入TASK_ID" allow-clear />
            </a-form-item>
            <a-form-item label="TASK_NAME：" name="taskName">
                <a-input v-model:value="formData.taskName" placeholder="请输入TASK_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="WF_ACTOR_ID：" name="wfActorId">
                <a-input v-model:value="formData.wfActorId" placeholder="请输入WF_ACTOR_ID" allow-clear />
            </a-form-item>
            <a-form-item label="WF_ACTOR：" name="wfActor">
                <a-input v-model:value="formData.wfActor" placeholder="请输入WF_ACTOR" allow-clear />
            </a-form-item>
            <a-form-item label="WF_ACTOR_DEPT_ID：" name="wfActorDeptId">
                <a-input v-model:value="formData.wfActorDeptId" placeholder="请输入WF_ACTOR_DEPT_ID" allow-clear />
            </a-form-item>
            <a-form-item label="WF_ACTOR_DEPT：" name="wfActorDept">
                <a-input v-model:value="formData.wfActorDept" placeholder="请输入WF_ACTOR_DEPT" allow-clear />
            </a-form-item>
            <a-form-item label="IS_LEADER：" name="isLeader">
                <a-input v-model:value="formData.isLeader" placeholder="请输入IS_LEADER" allow-clear />
            </a-form-item>
            <a-form-item label="IS_PASS：" name="isPass">
                <a-input v-model:value="formData.isPass" placeholder="请输入IS_PASS" allow-clear />
            </a-form-item>
            <a-form-item label="AUDIT_IDEA：" name="auditIdea">
                <a-input v-model:value="formData.auditIdea" placeholder="请输入AUDIT_IDEA" allow-clear />
            </a-form-item>
            <a-form-item label="WF_INFO：" name="wfInfo">
                <a-input v-model:value="formData.wfInfo" placeholder="请输入WF_INFO" allow-clear />
            </a-form-item>
            <a-form-item label="PROC_ID：" name="procId">
                <a-input v-model:value="formData.procId" placeholder="请输入PROC_ID" allow-clear />
            </a-form-item>
            <a-form-item label="ACTDEF_ID：" name="actdefId">
                <a-input v-model:value="formData.actdefId" placeholder="请输入ACTDEF_ID" allow-clear />
            </a-form-item>
            <a-form-item label="ACT_INST_ID：" name="actInstId">
                <a-input v-model:value="formData.actInstId" placeholder="请输入ACT_INST_ID" allow-clear />
            </a-form-item>
            <a-form-item label="INITIATOR_ID：" name="initiatorId">
                <a-input v-model:value="formData.initiatorId" placeholder="请输入INITIATOR_ID" allow-clear />
            </a-form-item>
            <a-form-item label="XREF：" name="xref">
                <a-input v-model:value="formData.xref" placeholder="请输入XREF" allow-clear />
            </a-form-item>
            <a-form-item label="SYS_PARTY_CODE：" name="sysPartyCode">
                <a-input v-model:value="formData.sysPartyCode" placeholder="请输入SYS_PARTY_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="USABLE_STATUS：" name="usableStatus">
                <a-input v-model:value="formData.usableStatus" placeholder="请输入USABLE_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="CREATE_DATE：" name="createDate">
                <a-date-picker v-model:value="formData.createDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择CREATE_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="WF_TIME：" name="wfTime">
                <a-date-picker v-model:value="formData.wfTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择WF_TIME" style="width: 100%" />
            </a-form-item>
            <a-form-item label="CREATE_IP：" name="createIp">
                <a-input v-model:value="formData.createIp" placeholder="请输入CREATE_IP" allow-clear />
            </a-form-item>
            <a-form-item label="CREATE_USER_ID：" name="createUserId">
                <a-input v-model:value="formData.createUserId" placeholder="请输入CREATE_USER_ID" allow-clear />
            </a-form-item>
            <a-form-item label="MODIFY_DATE：" name="modifyDate">
                <a-date-picker v-model:value="formData.modifyDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择MODIFY_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="MODIFY_IP：" name="modifyIp">
                <a-input v-model:value="formData.modifyIp" placeholder="请输入MODIFY_IP" allow-clear />
            </a-form-item>
            <a-form-item label="MODIFY_USER_ID：" name="modifyUserId">
                <a-input v-model:value="formData.modifyUserId" placeholder="请输入MODIFY_USER_ID" allow-clear />
            </a-form-item>
            <a-form-item label="ORDER_CODE：" name="orderCode">
                <a-input v-model:value="formData.orderCode" placeholder="请输入ORDER_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE1：" name="attribute1">
                <a-input v-model:value="formData.attribute1" placeholder="请输入ATTRIBUTE1" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE2：" name="attribute2">
                <a-input v-model:value="formData.attribute2" placeholder="请输入ATTRIBUTE2" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE3：" name="attribute3">
                <a-input v-model:value="formData.attribute3" placeholder="请输入ATTRIBUTE3" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE4：" name="attribute4">
                <a-input v-model:value="formData.attribute4" placeholder="请输入ATTRIBUTE4" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE5：" name="attribute5">
                <a-input v-model:value="formData.attribute5" placeholder="请输入ATTRIBUTE5" allow-clear />
            </a-form-item>
            <a-form-item label="WF_START_TIME：" name="wfStartTime">
                <a-date-picker v-model:value="formData.wfStartTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择WF_START_TIME" style="width: 100%" />
            </a-form-item>
            <a-form-item label="AUDIT_INFO_OPERATE：" name="auditInfoOperate">
                <a-input v-model:value="formData.auditInfoOperate" placeholder="请输入AUDIT_INFO_OPERATE" allow-clear />
            </a-form-item>
            <a-form-item label="AUDIT_INFO_SOURCE：" name="auditInfoSource">
                <a-input v-model:value="formData.auditInfoSource" placeholder="请输入AUDIT_INFO_SOURCE" allow-clear />
            </a-form-item>
            <a-form-item label="NEXT_STEP_ID：" name="nextStepId">
                <a-input v-model:value="formData.nextStepId" placeholder="请输入NEXT_STEP_ID" allow-clear />
            </a-form-item>
            <a-form-item label="NEXT_STEP_NAME：" name="nextStepName">
                <a-input v-model:value="formData.nextStepName" placeholder="请输入NEXT_STEP_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="NEXT_STEP_USER_NAME：" name="nextStepUserName">
                <a-input v-model:value="formData.nextStepUserName" placeholder="请输入NEXT_STEP_USER_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="NEXT_STEP_USER_PARTYID：" name="nextStepUserPartyid">
                <a-input v-model:value="formData.nextStepUserPartyid" placeholder="请输入NEXT_STEP_USER_PARTYID" allow-clear />
            </a-form-item>
            <a-form-item label="NEXT_STEP_ACTION：" name="nextStepAction">
                <a-input v-model:value="formData.nextStepAction" placeholder="请输入NEXT_STEP_ACTION" allow-clear />
            </a-form-item>
            <a-form-item label="AUDIT_STEP_TYPE：" name="auditStepType">
                <a-input v-model:value="formData.auditStepType" placeholder="请输入AUDIT_STEP_TYPE" allow-clear />
            </a-form-item>
            <a-form-item label="COUNTERSIGN_LOGO：" name="countersignLogo">
                <a-input v-model:value="formData.countersignLogo" placeholder="请输入COUNTERSIGN_LOGO" allow-clear />
            </a-form-item>
            <a-form-item label="BRANCH_SIGN_NAME：" name="branchSignName">
                <a-input v-model:value="formData.branchSignName" placeholder="请输入BRANCH_SIGN_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="BRANCH_SIGN_CODE：" name="branchSignCode">
                <a-input v-model:value="formData.branchSignCode" placeholder="请输入BRANCH_SIGN_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="BRANCH_SIGN_TASK_ID：" name="branchSignTaskId">
                <a-input v-model:value="formData.branchSignTaskId" placeholder="请输入BRANCH_SIGN_TASK_ID" allow-clear />
            </a-form-item>
            <a-form-item label="WF_AUTHORIZE_TYPE：" name="wfAuthorizeType">
                <a-input v-model:value="formData.wfAuthorizeType" placeholder="请输入WF_AUTHORIZE_TYPE" allow-clear />
            </a-form-item>
            <a-form-item label="WF_AUTHORIZE_PARTYID：" name="wfAuthorizePartyid">
                <a-input v-model:value="formData.wfAuthorizePartyid" placeholder="请输入WF_AUTHORIZE_PARTYID" allow-clear />
            </a-form-item>
            <a-form-item label="WF_AUTHORIZE_CODE：" name="wfAuthorizeCode">
                <a-input v-model:value="formData.wfAuthorizeCode" placeholder="请输入WF_AUTHORIZE_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="WF_AUTHORIZE_NMAE：" name="wfAuthorizeNmae">
                <a-input v-model:value="formData.wfAuthorizeNmae" placeholder="请输入WF_AUTHORIZE_NMAE" allow-clear />
            </a-form-item>
            <a-form-item label="APPROVAL_USE_TIME：" name="approvalUseTime">
                <a-input v-model:value="formData.approvalUseTime" placeholder="请输入APPROVAL_USE_TIME" allow-clear />
            </a-form-item>
        </a-form>
        <template #footer>
            <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
            <a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
        </template>
    </a-drawer>
</template>

<script setup name="flwAuditInfoForm">
    import { cloneDeep } from 'lodash-es'
    import { required } from '@/utils/formRules'
    import flwAuditInfoApi from '@/api/biz/flwAuditInfoApi'
    // 抽屉状态
    const visible = ref(false)
    const emit = defineEmits({ successful: null })
    const formRef = ref()
    // 表单数据
    const formData = ref({})
    const submitLoading = ref(false)

    // 打开抽屉
    const onOpen = (record) => {
        visible.value = true
        if (record) {
            let recordData = cloneDeep(record)
            formData.value = Object.assign({}, recordData)
        }
    }
    // 关闭抽屉
    const onClose = () => {
        formRef.value.resetFields()
        formData.value = {}
        visible.value = false
    }
    // 默认要校验的
    const formRules = {
    }
    // 验证并提交数据
    const onSubmit = () => {
        formRef.value
            .validate()
            .then(() => {
                submitLoading.value = true
                const formDataParam = cloneDeep(formData.value)
                flwAuditInfoApi
                    .flwAuditInfoSubmitForm(formDataParam, !formDataParam.wfAuditInfoId)
                    .then(() => {
                        onClose()
                        emit('successful')
                    })
                    .finally(() => {
                        submitLoading.value = false
                    })
            })
    }
    // 抛出函数
    defineExpose({
        onOpen
    })
</script>
